home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / ODF / Tools / Mac / CWPPCProfiler / ODFCWProfilerLib.cpp < prev    next >
Encoding:
Text File  |  1996-09-17  |  2.1 KB  |  70 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                ODFCWProfilerLib.cpp
  4. //    Release Version:    $ ODF 2 $ 
  5. //
  6. //    Copyright:    (c) 1993-1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10.  
  11. #ifndef __CODEFRAGMENTS__
  12. #include <CodeFragments.h>
  13. #endif
  14.  
  15. #ifndef FWPROFILER_H
  16. #include "FWProfiler.h"
  17. #endif
  18.  
  19. #ifndef __PROFILER__
  20. #include <Profiler.h>
  21. #endif
  22.  
  23. #ifndef _STDLIB
  24. #include <stdlib.h>
  25. #endif
  26.  
  27. //========================================================================================
  28. // Prototypes
  29. //========================================================================================
  30.  
  31. extern "C" pascal OSErr ODF_CWPROFLIB_CFMINIT(CFragInitBlockPtr initBlkPtr);
  32. extern "C" pascal void  ODF_CWPROFLIB_CFMTERM(void);
  33. extern "C" short __initialize(void);
  34. extern "C" void    __terminate(void);
  35.  
  36. //========================================================================================
  37. // Initialization methods
  38. //========================================================================================
  39.  
  40. //----------------------------------------------------------------------------------------
  41. // ODF_LIBRARY_CFMINIT (Has to be upper case because of the 68K Linker)
  42. //----------------------------------------------------------------------------------------
  43.  
  44. extern "C" pascal OSErr ODF_CWPROFLIB_CFMINIT(CFragInitBlockPtr)
  45. {
  46.     // Shared libraries don't get their static objects initialized correctly without
  47.     // calling __initialize or __CPlusInit for MetroWerks or MrC respectively.
  48.     __initialize();
  49.     
  50.     OSErr profilerErr = ProfilerInit(collectDetailed, bestTimeBase, 100, 20);
  51.     if (profilerErr == noErr)
  52.         ProfilerSetStatus(false);    // default to explicit profiling
  53.  
  54.     return profilerErr;
  55. }
  56.  
  57. //----------------------------------------------------------------------------------------
  58. // ODFCFMTERM
  59. //----------------------------------------------------------------------------------------
  60.  
  61. extern "C" pascal void ODF_CWPROFLIB_CFMTERM(void)
  62. {
  63.     if (FW_ProfilerGetStatus())
  64.         FW_ProfilerDump();
  65.     
  66.     ProfilerTerm();
  67.     
  68.     __terminate();
  69. }
  70.